<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:ItemsViewer">


    <Style TargetType="{x:Type local:ItemsViewerControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ItemsViewerControl}">
                    <Border SnapsToDevicePixels="true"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            Padding="{TemplateBinding Padding}">
                        <local:AnimatedScrollViewer Grid.Row="1"
                                               x:Name="AniScrollViewer"
                                               HorizontalScrollBarVisibility="Auto"
                                               VerticalScrollBarVisibility="Auto"
                                               CanContentScroll="True">
                            <ItemsPresenter x:Name="itemsPresenter"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </local:AnimatedScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <local:AnimatedVirtualizingWrapPanel IsItemsHost="True"
                                                         x:Name="itemsPanel">
                    </local:AnimatedVirtualizingWrapPanel>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment"
                            Value="Left" />
                    <Setter Property="VerticalContentAlignment"
                            Value="Top" />
                    <Setter Property="Background"
                            Value="Transparent" />
                    <Setter Property="BorderThickness"
                            Value="1" />
                    <Setter Property="FocusVisualStyle"
                            Value="{x:Null}" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListBoxItem">
                                <Grid Background="{TemplateBinding Background}">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="MouseOver">
                                                <Storyboard>
                                                    <ColorAnimation Storyboard.TargetName="BorderColor"
                                                                    Storyboard.TargetProperty="BorderBrush.Color"
                                                                    To="#FFBADDE9"
                                                                    Duration="0:0:0.1" />
                                                    <DoubleAnimation Storyboard.TargetName="contentPresenter"
                                                                     Storyboard.TargetProperty="Opacity"
                                                                     Duration="0:0:0.5"
                                                                     To="1" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Disabled">
                                                <Storyboard>
                                                    <DoubleAnimation Storyboard.TargetName="contentPresenter"
                                                                     Storyboard.TargetProperty="Opacity"
                                                                     Duration="0"
                                                                     To=".55" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="SelectionStates">
                                            <VisualState x:Name="Unselected" />
                                            <VisualState x:Name="Selected">
                                                <Storyboard>
                                                    <ColorAnimation Storyboard.TargetName="BorderColor2"
                                                                    Storyboard.TargetProperty="BorderBrush.Color"
                                                                    To="#FFBADDE9"
                                                                    Duration="0:0:0.1" />
                                                    <DoubleAnimation Storyboard.TargetName="contentPresenter"
                                                                     Storyboard.TargetProperty="Opacity"
                                                                     Duration="0:0:0.5"
                                                                     To="1" />
                                                </Storyboard>
                                            </VisualState>
                                        </VisualStateGroup>
                                        <VisualStateGroup x:Name="FocusStates">
                                            <VisualState x:Name="Focused">
                                            </VisualState>
                                            <VisualState x:Name="Unfocused" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Border x:Name="BorderColor"
                                            BorderBrush="Transparent"
                                            BorderThickness="2"
                                            CornerRadius="1"
                                            IsHitTestVisible="False"
                                            Padding="3"
                                            Margin="3">
                                    </Border>
                                    <Border x:Name="BorderColor2"
                                            BorderBrush="Transparent"
                                            BorderThickness="2"
                                            CornerRadius="1"
                                            IsHitTestVisible="False"
                                            Padding="3"
                                            Margin="3">
                                    </Border>
                                    <ContentPresenter x:Name="contentPresenter"
                                                      Opacity="0.9"
                                                      Content="{TemplateBinding Content}"
                                                      ContentTemplate="{TemplateBinding ContentTemplate}"
                                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                      Margin="10" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>


            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
